<template>
  <div
    class="site-wrapper"
    :class="{ 'site-sidebar--fold': sidebarFold }"
    v-loading.fullscreen.lock="loading"
    element-loading-text="拼命加载中"
  >
    <template v-if="!loading">
      <main-navbar />
      <main-sidebar />
      <div
        class="site-content__wrapper"
        :style="{ 'min-height': documentClientHeight + 'px' }"
      >
        <main-content v-if="!$store.state.common.contentIsNeedRefresh" />
      </div>
    </template>
  </div>
</template>

<script>
import MainContent from "./main-content";
import MainNavbar from "./main-navbar";
import MainSidebar from "./main-sidebar";

export default {
  provide() {
    return {
      // 刷新
      refresh() {
        this.$store.commit("common/updateContentIsNeedRefresh", true);
        this.$nextTick(() => {
          this.$store.commit("common/updateContentIsNeedRefresh", false);
        });
      }
    };
  },
  data() {
    return {
      loading: true
    };
  },
  components: {
    MainNavbar,
    MainSidebar,
    MainContent
  },
  computed: {
    documentClientHeight: {
      get() {
        return this.$store.state.common.documentClientHeight;
      },
      set(val) {
        this.$store.commit("common/updateDocumentClientHeight", val);
      }
    },
    sidebarFold: {
      get() {
        return this.$store.state.common.sidebarFold;
      }
    },
    id: {
      get() {
        return this.$store.state.user.id;
      },
      set(val) {
        this.$store.commit("user/updateId", val);
      }
    },
    account: {
      get() {
        return this.$store.state.user.account;
      },
      set(val) {
        this.$store.commit("user/updateName", val);
      }
    }
  },
  created() {
    this.getUserInfo();
  },
  mounted() {
    this.resetDocumentClientHeight();
  },
  methods: {
    // 重置窗口可视高度
    resetDocumentClientHeight() {
      this.documentClientHeight = document.documentElement["clientHeight"];
      window.onresize = () => {
        this.documentClientHeight = document.documentElement["clientHeight"];
      };
    },
    // 获取当前管理员信息
    getUserInfo() {
      this.$http({
        url: this.$http.adornUrl("/sys/user/info"),
        method: "get",
        params: this.$http.adornParams()
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.loading = false;
          this.id = data.user.userId;
          this.account = data.user.username;
        }
      });
    }
  }
};
</script>
<style lang="scss">
$normalWidth: 120px;
$miniWidth: 70px;
$mediumWidth: 150px;
$normalInputHeight: 32px;
$seachFontsize: 12px;

/* 页面显示的版本 */
.mainBody {
  padding: 40px 0 0 !important;
  .theContentTab {
    > .el-tabs__content {
      padding: 0 !important;
      .el-tab-pane {
        .el-card {
          .el-card__body {
            padding: 10px 10px;
          }
        }
      }
    }
  }
}

.formSearch {
  .el-form-item {
    margin: 10px 10px 10px 0;
  }
}

/*
!* 泵站流量计弹窗查询 *!
.bengDialog {
  .el-dialog {
    width: 90%;
    min-width: 800px;
    max-height: 80vh;
    margin-top: 10vh !important;
    .el-dialog__header {
      padding: 15px;
      border-bottom: 1px #dcdcdc solid;
    }
    .el-dialog__body {
      overflow-x: hidden;
      overflow-y: auto;
      max-height: calc(80vh - 120px);
      padding: 0 15px;
      .formSearch {
        .el-form-item {
          margin: 10px 10px 10px 0;
        }
      }
    }
    .el-dialog__footer {
      padding: 15px;
      border-top: 1px #dcdcdc solid;
    }
  }
}*/

/* 日常抄表记录新增弹窗 */
.dailyDialog {
  .el-dialog {
    width: 50%;
    min-width: 720px;
    max-height: 80vh;
    margin-top: 10vh !important;
    .el-dialog__header {
      padding: 15px;
      border-bottom: 1px #dcdcdc solid;
    }
    .el-dialog__body {
      overflow-x: hidden;
      overflow-y: auto;
      max-height: calc(80vh - 120px);
      padding: 15px 15px 0 15px;
      .formAddOrUpdate {
        .el-form-item {
          margin: 0 0 15px;
          width: 50%;
          .el-form-item__label {
            color: #000;
            width: 100px !important;
          }
          .el-form-item__content {
            width: calc(100% - 120px);
            .el-date-editor {
              width: 100%;
            }
            .el-input {
              width: 100%;
            }
          }
          .el-date-picker,
          .el-select {
            width: 100%;
          }
        }
        .box {
          // 一行一个盒子
          display: flex;
          justify-items: stretch;
          padding-bottom: 15px;
          width: 100%;
        }
        .box1 {
          display: flex;
          justify-items: stretch;
          padding-bottom: 15px;
          width: 100%;
          .el-form-item {
            .el-form-item__content {
              width: 82%;
            }
            flex-grow: 1;
          }
        }
      }
    }
    .el-dialog__footer {
      padding: 15px;
      border-top: 1px #dcdcdc solid;
    }
  }
}

/* tab切换 */
.tabPart {
  position: relative;
  .el-tabs__header {
    width: 180px;
    .el-tabs__nav-wrap {
      border-left: 1px #efefef solid;
      border-bottom: 1px #efefef solid;
      .el-tabs__nav-scroll {
        .el-tabs__nav {
          border-top: 1px #efefef solid;
          white-space: normal;
          .el-tabs__active-bar {
            height: auto !important;
          }
          .el-tabs__item {
            padding: 10px 10px 10px 5px !important;
            word-break: break-all;
            height: auto;
            line-height: 1.6;
            font-size: 14px;
            border-bottom: 1px #efefef solid;
          }
          .is-active {
            background-color: #409eff !important;
            color: #fff !important;
          }
        }
      }
    }
  }
  .el-tabs__content {
    overflow-x: hidden;
    overflow-y: auto;
    height: 80vh;
  }
}

/* 每日汇总样式 */
.firstTable {
  position: relative;
  width: 50%;
  margin: 0 0 15px;
  border-right: 1px #efefef solid;
  float: left;
  overflow: hidden;
  .tableSelect {
    width: 100%;
    overflow: auto;
    position: relative;
    display: flex;
    .leftNameList {
      height: 100%;
      width: 120px;
      border-left: 1px #efefef solid;
      display: inline-flex;
      flex-wrap: wrap;
      .headBox {
        background-color: #fcfcfc;
      }
      .nameBlock {
        height: 40px;
        overflow: hidden;
        border-top: 1px #efefef solid;
        border-right: 1px #efefef solid;
        font-size: 12px;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 8px;
        &:last-child {
          border-bottom: 1px #efefef solid;
        }
      }
    }
    .rightDataPart {
      overflow-x: auto;
      overflow-y: hidden;
      position: relative;
      width: calc(100% - 120px);
      display: flex;
      border-bottom: 1px #efefef solid;
      .rightNameList {
        height: 100%;
        width: 120px;
        flex: 0 0 120px;
        .headBox {
          background-color: #fcfcfc;
        }
        .nameBlock {
          height: 40px;
          overflow: hidden;
          border-top: 1px #efefef solid;
          border-right: 1px #efefef solid;
          font-size: 12px;
          width: 100%;
          display: flex;
          align-items: center;
          justify-content: center;
          padding: 0 8px;
        }
      }
    }
  }
}

.missionPart {
  .el-dialog {
    position: relative;
    width: 80%;
    margin: 10vh auto !important;
    height: 80vh;
    .el-dialog__header {
      position: relative;
      padding: 15px;
      border-bottom: 1px #efefef solid;
      .el-dialog__title {
        color: #333;
      }
    }
    .el-dialog__footer {
      border-top: 1px #efefef solid;
      padding: 15px;
    }
    .el-dialog__body {
      height: calc(80vh - 55px - 67px);
      overflow-x: hidden;
      overflow-y: auto;
      padding: 15px;
      .tablePart {
        position: relative;
        overflow: hidden;
        .el-form-item {
          margin: 0 0 15px;
          width: 50%;
          display: inline-block;
          float: left;
          .el-form-item__label {
            font-size: 14px;
            line-height: 32px;
          }
          .el-form-item__content {
            line-height: 32px;
            .el-select {
              width: 100%;
            }
            .el-date-editor {
              width: 100%;
            }
            .el-radio-group {
              line-height: 36px;
            }
          }
        }
        .fullList {
          width: 100%;
        }
        .longList {
          .el-form-item__label {
            width: 210px !important;
          }
        }
      }
      .tranglePart {
        position: relative;
        overflow: hidden;
        .el-form-item {
          margin: 0 0 15px;
          width: 33.333333%;
          display: inline-block;
          float: left;
          .el-form-item__label {
            font-size: 14px;
            line-height: 32px;
          }
          .el-form-item__content {
            line-height: 32px;
            .el-select {
              width: 100%;
            }
            .el-date-editor {
              width: 100%;
            }
          }
        }
        .fullList {
          width: 100%;
          .el-form-item__content {
            line-height: 32px;
            .el-textarea {
              .el-textarea__inner {
                min-height: 60px !important;
              }
            }
          }
        }
      }
    }
  }
}
</style>
